package com.mapbased.wfw.handler;

import java.util.*;

import com.mapbased.wfw.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: mapbased.com</p>
 *
 * @author chy_hs(Baily)
 * @version 1.0
 */
public class TestHandler
    extends PageHandler
{

    public TestHandler()
    {
    }

    public String testBinding(java.util.Map m)
    {
        //res.getBundle()
        return "OK!";
    }

    Object[] locales;
    public void submitAction(com.mapbased.wfw.RenderContext ctx)
    {
        Map m=new java.util.HashMap();
        Map req=ctx.getRequestMap();
        String s=ctx.getRequest().getParameter("userName");
        if(s.length() < 10)
        {
            m.put("userName",this.getString("ShortLength"));
        }

        s=ctx.getRequest().getParameter("location");
        if(s.length() > 10)
        {
            m.put("location","location is to long");

        }
        req.put("valid_errors",m);

    }

    public Object[] localeBinding(java.util.Map m)
    {
        if(locales == null)
        {
            locales=java.util.Locale.getAvailableLocales();
        }

        return locales;
    }

    public String excuteTimeBinding(java.util.Map m)
    {
        Long l=(Long)m.get(Constants.Page_Start_Time);
        if(l != null)
        {
            return(System.currentTimeMillis() - l.longValue()) + " ms";
        }
        return "Not fetch";
    }



}
